package com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.assetFixedBorrow.service.SmsAssetMyAssetsService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * <p>
 * 我的资产 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-06-04
 */
@RestController
@RequestMapping("/assetFixedBorrow/myAssets")
@SecretBody
public class SmsAssetMyAssetsController {
    @Resource
    private SmsAssetMyAssetsService smsAssetMyAssetsService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @ApiModelProperty(value = "获取我的资产列表")
    @GetMapping("/list")
    public ResponseResult getFixedStorage(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                          @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                          @RequestParam(value = "asset_name", required = false) String asset_name,
                                          @RequestParam(value = "asset_model", required = false) String asset_model,
                                          @RequestParam(value = "asset_brand", required = false) String asset_brand,
                                          @RequestParam(value = "asset_category_id", required = false) String asset_category_id,
                                          @RequestParam(value = "my_asset_status", required = false) Integer my_asset_status,
                                          @RequestParam(value = "asset_price", required = false) BigDecimal asset_price,
                                          @RequestParam(value = "asset_place", required = false) String asset_place,
                                          HttpServletRequest request
    ) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsAssetMyAssetsService.getMyAssetList(asset_name, asset_model, asset_brand, asset_category_id,
                my_asset_status, asset_price, asset_place, pageSize, pageNum, user_id);
    }

}

